package utils

import (
	"go-cmd/top/process"
	"sort"
)

// Implement the interface of sort
type TopSlice []process.ProcessProperty

func (r TopSlice) Len() int {
	return len(r)
}

func (r TopSlice) Less(i, j int) bool {
	return r[i].MemPercent > r[j].MemPercent
}

func (r TopSlice) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func Sort(data TopSlice) {
	sort.Sort(data)
}
